﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data;
using System.Dynamic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Xml;
using System.Xml.Linq;
using Unis.Framework.Core.Utility;
using KingRoad.EPM.PersonnelLogEntity.Model;
using KingRoad.EPM.Web.Areas.PersonnelLog.ViewModels;
using KingRoad.EPM.Web.Areas.PersonnelLog.PersonnelLogFramework.Common;


namespace KingRoad.EPM.Web.Areas.PersonnelLog.Controllers
{
    public class PlmConstructionLogCivilController : BaseController
    {

        private string dynamicHtml = "";
        private int maxLevel = 0;

        /// <summary>
        /// 施工日志-土建
        /// </summary>
        /// <returns></returns>
        public ActionResult ConstructionLogCivilList(string templeteId)
        {

            //var vm = new PlmConstructionlogcivilViewModel();
            ////TODO：此处应该有权限接入

            var supervison = "";
            if (ShiGong_Segment != null)
            {
                var dtSupervision = new KingRoad.EPM.ProjectInfoBLL.Project_SegmentBLL().GetVerifyBySegmentId(ShiGong_Segment.FirstOrDefault().SEGMENT_ID);
                supervison = dtSupervision.Rows[0]["SUPERVISION_CODE"].ToString();
            }

            var list = PlmConstructionlogcivilUIRule.GetInfoListGroupByDirectorSection(supervison);
            //vm.ThePlmConstructlogcivilList = list;
            ViewBag.templeteId = templeteId;
            //return View(vm);
            int totalRecord = 0;
            //当前页码
            ViewBag.pageNum = 1;
            //每页多少条
            ViewBag.numPerPage = 20;

            var splitList = PlmDailysupervisionUIRule.GetEntityListByContionRe<PlmConstructionlogcivilInfo>(ViewBag.pageNum,
            ViewBag.numPerPage, "Clc_ConstructionDate", list);


            //var list = PlmConstructionlogcivilUIRule.GetAltPlmConstructionlogForPage(ViewBag.pageNum, ViewBag.numPerPage, "Clc_ConstructionDate", out totalRecord, "");
            //总条数
            ViewBag.totalcount = totalRecord;
            //总页数
            ViewBag.pagenumshown = totalRecord % ViewBag.numPerPage == 0 ? totalRecord / ViewBag.numPerPage : totalRecord / ViewBag.numPerPage + 1;
            return View(new PlmConstructionlogcivilViewModel { ThePlmConstructlogcivilList = splitList });
        }
        /// <summary>
        /// 施工日志-土建添加页面
        /// </summary>
        /// <returns></returns>
        public ActionResult ConstructionLogCivilAdd(string target, string templeteId, string constructionDate)
        {
            ViewBag.target = target;
            var xmlPath = Server.MapPath("~/Areas/PersonnelLog/UnisYLXSetting/XML/施工日志配置模板.xml");
            var templateDoc = LinqLoadXmlFromPath(xmlPath);
            var nodes = templateDoc.Descendants("template-type").ToList().Where(t => t.Attribute("id").Value == templeteId).ToList();
            var levelNodes = nodes.FirstOrDefault().Descendants("level1").ToList();

            //获取模块ID
            ViewBag.MoudleID = GetEntityByUrl(Models.PageURL.施工_土建_日志);

            //附件目录名
            ViewBag.DirWhere = Models.DirName.施工_土建_日志;

            if (target == "add")
            {
                if (GetLoginUserOrganizeEntity.Code == null)
                {
                    return Content("<script>alert('当前用户没有添加权限,请使用拥有权限的人员登录后添加!')</script>");
                }

                var assisId = GenerateRandom();
                var assisIdRet = 0;
                CreateAssistId(PlmConstructionlogcivilUIRule, assisId, out assisIdRet);
                ViewBag.AssisId = assisIdRet;

                ViewBag.LoginUserId = GetLoginUserId;
                ViewBag.LoginUserName = GetLoginUserName;
                var shi_gong = ShiGong_Segment.FirstOrDefault();
                ViewBag.ConstructionSection = "(" + shi_gong.SEGMENT_CODE + ")" + shi_gong.SEGMENT_NAME;
                ViewBag.ConstructionName = shi_gong.SEGMENT_DEPARTNAME;
                GetTemplateHtml(levelNodes, null);

                ViewBag.dynamicHtml = dynamicHtml;
                return View();
            }

            else
            {


                if (GetLoginUserOrganizeEntity.Code == null)
                {
                    return Content("<script>alert('当前用户没有修改权限,请使用拥有权限的人员登录后修改!')</script>");
                }

                var constructDate = constructionDate.Split('$')[0];
                var directorSection = constructionDate.Split('$')[1];

                var vm = new PlmConstructionlogcivilViewModel();
                //TODO:根据权限，施工单位可以修改，并且状态数据状态是没有评述的状态
                var constructionId = GetSeglist.FirstOrDefault().SEGMENT_ID.ToString();//当前登陆人施工单位ID
                //一天只有一条数据
                var dayRpt = PlmConstructionlogcivilUIRule.GetInfoListByConditionDT(directorSection, constructDate, "", constructionId);
                if (dayRpt.Rows.Count > 0)
                {
                    ViewBag.LoginUserId = GetLoginUserId;
                    ViewBag.LoginUserName = GetLoginUserName;
                    var shi_gong = ShiGong_Segment.FirstOrDefault();
                    ViewBag.ConstructionSection = "(" + shi_gong.SEGMENT_CODE + ")" + shi_gong.SEGMENT_NAME;
                    ViewBag.ConstructionName = shi_gong.SEGMENT_DEPARTNAME;
                    ViewBag.Clc_Remark = dayRpt.Rows[0]["Clc_Remark"];


                    GetTemplateHtml(levelNodes, dayRpt.Rows[0]);
                    ViewBag.ClC_Id = dayRpt.Rows[0]["Clc_ID"].ToString();

                    //附件
                    var commonFileList = CommonFileUIRule.GetCommonFilesByConditon(Convert.ToInt32(dayRpt.Rows[0]["Assist_ID"]), "ConstructionlogCivil_Rules");//SafeKnowledge_Rules  BizType类型
                    ViewBag.AssisId = Convert.ToInt32(dayRpt.Rows[0]["Assist_ID"]);
                    ViewBag.FileIds = string.Join(",", commonFileList.Select(t => t.FILE_FILEID));
                    ViewBag.DeleteIds = string.Join(",", commonFileList.Select(t => t.FILE_ID));

                    ViewBag.Clc_ConstructionDate = Convert.ToDateTime(dayRpt.Rows[0]["Clc_ConstructionDate"]).ToString("yyyy-MM-dd");
                }

                ViewBag.dynamicHtml = dynamicHtml;
                return View();
            }
        }

        private void GetTemplateHtml(List<XElement> levleNoes, DataRow dr)
        {
            levleNoes.ForEach(t =>
            {
                if (t.Name.LocalName == "level1")
                    dynamicHtml += GroupHtml(t);
                else
                    dynamicHtml += ItemHtml(t, dr);
                if (t.Elements().Any())
                    GetTemplateHtml(t.Elements().ToList(), dr);
            });
        }


        private string GroupHtml(XElement element)
        {
            var name = element.GetXmlAttributeValue<string>("name");
            var strHtml = String.Format(@"<div class=""divider""></div><h3>&nbsp;{0}</h3>", name);
            return strHtml;
        }


        private string ItemHtml(XElement element, DataRow dr)
        {
            string name, id, controlType, ctrlType = "", ctrlClass = "";

            var visiable = element.GetXmlAttributeValue<bool>("visiable");
            //是否是字段
            var isField = element.GetXmlAttributeValue<bool>("is-field");
            if (!visiable || !isField) return "";
            //节点名称
            name = element.GetXmlAttributeValue<string>("name");
            //节点ID
            id = element.GetXmlAttributeValue<string>("id");

            controlType = element.GetXmlAttributeValue<string>("control-type");

            if (!String.IsNullOrEmpty(controlType))
            {
                ctrlType = controlType.Split(':')[0];
                ctrlClass = controlType.Split(':')[1];
                if (!String.IsNullOrEmpty(ctrlClass))
                    ctrlClass = ctrlClass.Substring(1, ctrlClass.Length - 2);
            }

            var strHtml = "";
            var itemValue = "";
            if (dr != null)
            {
                if (dr.Table.Columns.Contains(id))
                    itemValue = dr[id].ToString();
            }
            if (ctrlType == "text")
            {
                strHtml = String.Format(@"<dl class=""nowrap"">
                                            <dt>{2}：</dt>
                                            <dd>
                                                <input id=""{0}"" name=""{0}"" type=""text""  {1}  class=""textInput"" value=""{3}""/> 
                                            </dd>
                                          </dl>", id, ctrlClass, name, itemValue);
            }
            else if (ctrlType == "textarea")
            {
                strHtml = String.Format(@"<dl class=""nowrap"">
                                            <dt>{2}：</dt>
                                            <dd>
                                                <textarea  id=""{0}"" name=""{0}"" {1} class=""textInput"" >{3}</textarea> 
                                            </dd>
                                          </dl>", id, ctrlClass, name, itemValue);
            }
            return strHtml;
        }

        /// <summary>
        /// 施工日志-土建添加动作
        /// </summary>
        /// <returns></returns>
        public JsonResult ConstructionLogCivilAddHandle(string target, FormCollection collection)
        {
            var dicFormValue = new Dictionary<string, string>();
            dynamic jsonReturn = new ExpandoObject();
            string operation_str = string.Empty;
            var isScuess = TryCatchCommand.TryExec(() =>
            {
                var shi_gong = ShiGong_Segment.FirstOrDefault();

                //根据施工标段ID查询监理
                var dtSupervision = new KingRoad.EPM.ProjectInfoBLL.Project_SegmentBLL().GetVerifyBySegmentId(shi_gong.SEGMENT_ID);
                var supervisionCode = dtSupervision.Rows[0]["SUPERVISION_CODE"].ToString();
                var supervisionName = dtSupervision.Rows[0]["SUPERVISION_NAME"].ToString();


                //根据施工标段ID查询驻地监理
                var dtSupervising = new KingRoad.EPM.ProjectInfoBLL.Project_SegmentBLL().GetSupervisingBySegmentId(shi_gong.SEGMENT_ID);
                var supervisingCode = dtSupervising.Rows[0]["Supervising_Code"].ToString();
                var supervisingName = dtSupervising.Rows[0]["Supervising_Name"].ToString();

                collection.AllKeys.ToList().ForEach(t =>
                    {
                        if (t != "attachment.fileName" && t != "attachment.id")
                        {

                            var value = collection.GetValue(t).AttemptedValue;
                            if (t == "Clc_ConstructionDate" && String.IsNullOrEmpty(value))
                            {
                                value = DateTime.Now.ToString();
                            }
                            dicFormValue.Add(t, value);
                        }

                    });

                if (target == "add")
                {
                    operation_str = "添加";
                    //TODO：先暂时固定，后期需要登陆人的权限信息
                    dicFormValue.Add("Clc_ID", Guid.NewGuid().ToString());
                    dicFormValue.Add("Clc_DirectorSection", supervisionCode); //总监办标段-先暂时固定
                    dicFormValue.Add("Clc_DirectorName", supervisionName); //总监办单位名称-先暂时固定
                    dicFormValue.Add("Clc_StationSection", supervisingCode); //驻地办标段-先暂时固定
                    dicFormValue.Add("Clc_StationName", supervisingName); //驻地办单位名称-先暂时固定
                    dicFormValue.Add("Clc_ContractNumber", shi_gong.SEGMENT_CODE); //合同号-先暂时固定
                    dicFormValue.Add("Clc_ConstructionID", GetSeglist.FirstOrDefault().SEGMENT_ID.ToString());//存储施工标段ID
                    dicFormValue.Add("Clc_State", "0");//添加评述状态
                    dicFormValue.Add("Assist_ID", Request.Form["AssistID"].ToString());//添加附件id

                    var ret = PlmConstructionlogcivilUIRule.InsterConstructionlogInfo(dicFormValue);
                }
                else
                {
                    operation_str = "更新";
                    dicFormValue.Add("Clc_DirectorSection", supervisionCode); //总监办标段-先暂时固定
                    dicFormValue.Add("Clc_DirectorName", supervisionName); //总监办单位名称-先暂时固定
                    dicFormValue.Add("Clc_StationSection", supervisingCode); //驻地办标段-先暂时固定
                    dicFormValue.Add("Clc_StationName", supervisingName); //驻地办单位名称-先暂时固定
                    dicFormValue.Add("Clc_ContractNumber", shi_gong.SEGMENT_CODE); //合同号-先暂时固定
                    dicFormValue.Add("Assist_ID", Request.Form["AssistID"].ToString());//添加附件id

                    var ret = PlmConstructionlogcivilUIRule.UpdateConstructionlogInfo(dicFormValue);
                }

            });
            if (isScuess)
            {
                jsonReturn = new { statusCode = "200", message = string.Format("{0}成功", operation_str), navTabId = "PersonnelLog.PlmConstructionLogCivil.ConstructionLogCivilList?templeteId=Cons_Log_Civil", rel = "", callbackType = "closeCurrent", forwardUrl = "", confirmMsg = "" };
            }
            else
            {
                jsonReturn = new { statusCode = "300", message = string.Format("{0}失败", operation_str) };
            }
            return new JsonResult()
            {
                Data = jsonReturn
            };
        }
        /// <summary>
        ///  施工日志-土建查看
        /// </summary>
        /// <param name="directorSection"></param>
        /// <param name="constructionDate"></param>
        /// <returns></returns>
        public ActionResult ConstructionLogCivilDetail(string constructionDate)
        {
            var constructDate = constructionDate.Split('$')[0];
            var directorSection = constructionDate.Split('$')[1];

            //TODO：需要根据权限来确认当前登陆人的信息
            var vm = new PlmConstructionlogcivilViewModel();
            var retList = new List<PlmConstructionlogcivilInfo>();

            KingRoad.EPM.ProjectInfoEntity.PROJECT_SEGMENT currentLoginSegment = null;

           


            switch (GetLoginUserOrganizeEntity.Code)
            {
                case "SG":
                    var list1 = PlmConstructionlogcivilUIRule.GetInfoListByCondition(directorSection, constructDate);
                    list1.ForEach(t =>
                    {
                        if (t.Clc_ConstructionID == GetSeglist.FirstOrDefault().SEGMENT_ID)
                            retList.Add(t);
                    });
                    break;
                case "ZDJL":
                    currentLoginSegment = GetZDJLProjectSegmentInfo.FirstOrDefault();
                    retList = PlmConstructionlogcivilUIRule.GetInfoListByCondition(directorSection, constructDate, currentLoginSegment.SEGMENT_CODE);
                    break;
                case "JL":
                    currentLoginSegment = GetJLProjectSegmentInfo.FirstOrDefault();
                    retList = PlmConstructionlogcivilUIRule.GetInfoListByCondition(directorSection, constructDate);
                    break;
            }
            if (GetLoginUserOrganizeEntity.Code == null)
            {
                currentLoginSegment = GetJLProjectSegmentInfo.FirstOrDefault();
                retList = PlmConstructionlogcivilUIRule.GetInfoListByCondition(directorSection, constructDate);
            }
            //TODO：先暂时固定，后续根据登陆人信息显示

            if (GetLoginUserOrganizeEntity.Code == "SG")
            {
                vm.ReportContractNum = GetSeglist.FirstOrDefault().SEGMENT_CODE; ;
                vm.ReportUnitName = GetSeglist.FirstOrDefault().SEGMENT_DEPARTNAME;
            }
            else
            {
                vm.ReportContractNum = currentLoginSegment.SEGMENT_CODE;
                vm.ReportUnitName = currentLoginSegment.SEGMENT_DEPARTNAME;
            }

            vm.ReportDate = constructDate;

            var sectionName = "";
            retList.ForEach(t =>
            {
                var section = t.Clc_ConstructionSection.Substring(t.Clc_ConstructionSection.IndexOf(")", StringComparison.Ordinal) + 1);
                sectionName += section + "$";
                vm.ReportTitle += section + "，";
            });

            if (!String.IsNullOrEmpty(vm.ReportTitle))
                vm.ReportTitle = vm.ReportTitle.Substring(0, vm.ReportTitle.Length - 1);
            if (!String.IsNullOrEmpty(sectionName))
                sectionName = sectionName.Substring(0, sectionName.Length - 1);
            vm.ReportSectionName = sectionName;

            //组合报表格式
            vm.GetType().GetProperties().Where(t => t.Name.StartsWith("Report_")).ToList().ForEach(t =>
            {
                var proptertyName = t.Name.Substring(t.Name.IndexOf("_", StringComparison.Ordinal) + 1);
                var value = "";
                retList.ForEach(r =>
                {
                    if (proptertyName == "Clc_Remark")
                    {
                        var biaoDuanHao = Reflection.GetProperty(r, "Clc_ContractNumber").ToString();

                        value += Reflection.GetProperty(r, proptertyName) == null ? "$"
                            : "<span style='font-weight: 600;'>(" + biaoDuanHao + ")备注：</span><br/>" + Reflection.GetProperty(r, proptertyName).ToString() + "$";
                    }
                    value += Reflection.GetProperty(r, proptertyName) == null ? "$"
                                                                              : Reflection.GetProperty(r, proptertyName).ToString() + "$";
                });
                if (!String.IsNullOrEmpty(value))
                    value = value.Substring(0, value.Length - 1);
                Reflection.SetProperty(vm, t.Name, value);
            });
            //获取模块ID
            ViewBag.MoudleID = GetEntityByUrl(Models.PageURL.施工_土建_日志);
            //附件目录名
            ViewBag.DirWhere = Models.DirName.施工_土建_日志;
            return View(vm);
        }


        /// <summary>
        /// 施工日志-土建评述
        /// </summary>
        /// <param name="directorSection"></param>
        /// <param name="constructionDate"></param>
        /// <returns></returns>
        public ActionResult ConstructionLogCivilComment(string constructionDate)
        {

            var constructDate = constructionDate.Split('$')[0];
            var directorSection = constructionDate.Split('$')[1];
            ViewBag.LoginRealName = base.GetLoginUserInfo.RealName;
            ViewBag.directorSection = directorSection;
            ViewBag.constructionDate = constructDate;
            //TODO：需要根据权限来确认当前登陆人的信息
            var vm = new PlmConstructionlogcivilViewModel();
            var retList = new List<PlmConstructionlogcivilInfo>();
            KingRoad.EPM.ProjectInfoEntity.PROJECT_SEGMENT currentLoginSegment = null;
            switch (GetLoginUserOrganizeEntity.Code)
            {
                case "SG":
                    var list1 = PlmConstructionlogcivilUIRule.GetInfoListByCondition(directorSection, constructDate);
                    list1.ForEach(t =>
                    {
                        if (t.Clc_ConstructionID == GetSeglist.FirstOrDefault().SEGMENT_ID)
                            retList.Add(t);
                    });
                    break;
                case "ZDJL":
                    currentLoginSegment = GetZDJLProjectSegmentInfo.FirstOrDefault();
                    retList = PlmConstructionlogcivilUIRule.GetInfoListByCondition(directorSection, constructDate, currentLoginSegment.SEGMENT_CODE);
                    break;
                case "JL":
                    currentLoginSegment = GetJLProjectSegmentInfo.FirstOrDefault();
                    retList = PlmConstructionlogcivilUIRule.GetInfoListByCondition(directorSection, constructDate);
                    break;
            }
            ViewBag.CurrentCode = GetLoginUserOrganizeEntity.Code;
            vm.ThePlmConstructlogcivilList = retList;
            return View(vm);
        }

        public ActionResult ConstructionLogCivilCommentSave(PlmConstructionlogcivilViewModel vm)
        {
            if (vm == null)
            {
                return new JsonResult()
                {
                    Data = new
                    {
                        statusCode = "300",
                        message = "操作失败",
                    }
                };
            }
            dynamic jsonReturn = new ExpandoObject();


            var currentCode = GetLoginUserOrganizeEntity.Code;

            var isScuess = TryCatchCommand.TryExec(() =>
            {
                var directorSection = vm.ThePlmConstructionlogcivilInfo.Clc_DirectorSection;

                var constructionDate = vm.ThePlmConstructionlogcivilInfo.Clc_ConstructionDate.ToString("yyyy-MM-dd");

                var retList = PlmConstructionlogcivilUIRule.GetInfoListByCondition(directorSection, constructionDate);

                vm.GetType().GetProperties().Where(t => t.Name.StartsWith("YLTJ")).ToList().ForEach(t =>
                {
                    var sectionCode = t.Name.Replace("_", "-");
                    var signle = retList.FirstOrDefault(f => f.Clc_ConstructionSection.Contains(sectionCode));
                    if (signle != null)
                    {
                        var value = Reflection.GetProperty(vm, t.Name);


                        switch (currentCode)
                        {
                            case "ZDJL":
                                Reflection.SetProperty(signle, "Clc_StationComment", value == null ? "" : value.ToString());
                                break;
                            case "JL":
                                Reflection.SetProperty(signle, "Clc_DirectorComment", value == null ? "" : value.ToString());
                                break;
                        }
                    }
                });
                //TODO:需要根据登陆用户，确认来使用这两个方法
                //更新总监办评述
                switch (currentCode)
                {
                    case "ZDJL":
                        PlmConstructionlogcivilUIRule.UpdateStationCommentInfo(retList);
                        break;
                    case "JL":
                        PlmConstructionlogcivilUIRule.UpdateDirectorCommentInfo(retList);
                        break;
                }
            });
            if (isScuess)
            {
                jsonReturn = new { statusCode = "200", message = "评述成功", navTabId = "PersonnelLog.PlmConstructionLogCivil.ConstructionLogCivilList?templeteId=Cons_Log_Civil", rel = "", callbackType = "closeCurrent", forwardUrl = "", confirmMsg = "" };
            }
            else
            {
                jsonReturn = new { statusCode = "300", message = "评述失败" };
            }
            return new JsonResult()
            {
                Data = jsonReturn
            };
        }

        public ActionResult ConstructionLogCivilDelete(string constructionDate)
        {
            if (GetLoginUserOrganizeEntity.Code == null)
            {
                return new JsonResult()
                {
                    Data = new
                    {
                        statusCode = "300",
                        message = "当前用户没有删除权限,请使用拥有权限的人员登录后删除!",
                    }
                };
            }
            //TODO:根据当前登陆人，如果是施工单位人员，根据信息，查出来，删除，如果状体是已经评述过的，则不能删除
            if (String.IsNullOrEmpty(constructionDate))
            {
                return new JsonResult()
                {
                    Data = new
                    {
                        statusCode = "300",
                        message = "删除失败",
                    }
                };
            }
            var constructDate = constructionDate.Split('$')[0];
            var directorSection = constructionDate.Split('$')[1];
            dynamic jsonReturn = new ExpandoObject();
            var isScuess = TryCatchCommand.TryExec(() =>
            {

                PlmConstructionlogcivilInfo deleEntity = null;

                if (GetLoginUserOrganizeEntity.Code == "SG")
                {
                    var list1 = PlmConstructionlogcivilUIRule.GetInfoListByCondition(directorSection, constructDate);


                    deleEntity = list1.FirstOrDefault(t => t.Clc_ConstructionID == GetSeglist.FirstOrDefault().SEGMENT_ID);

                    if (deleEntity != null && deleEntity.Clc_State == "0")
                    {
                        PlmConstructionlogcivilUIRule.DeleteObjById(deleEntity.Clc_ID);
                    }
                }

            });
            if (isScuess)
            {
                jsonReturn = new { statusCode = "200", message = "删除成功", navTabId = "PersonnelLog.PlmConstructionLogCivil.ConstructionLogCivilList?templeteId=Cons_Log_Civil", rel = "", callbackType = "", forwardUrl = "", confirmMsg = "" };
            }
            else
            {
                jsonReturn = new { statusCode = "300", message = "删除失败" };
            }
            return new JsonResult()
            {
                Data = jsonReturn
            };
        }

        public ActionResult SplitPage(PlmConstructionlogcivilViewModel vm)
        {
            int totalRecord = 0;
            //当前页码
            ViewBag.pageNum = Convert.ToInt32(Request.Form["pageNum"]);
            //每页多少条

            ViewBag.numPerPage = Convert.ToInt32(Request.Form["numPerPage"]);

            ViewBag.type = Request.Form["type"];
            ViewBag.time = Request.Form["time"];

            string sql = " 1=1 ";
            if (ViewBag.type != "")
                sql += " and Clc_DirectorSection='" + ViewBag.type + "' ";
            if (ViewBag.time != "")
                sql += " and Clc_ConstructionDate='" + ViewBag.time + "' ";


            var list = PlmConstructionlogcivilUIRule.GetAltPlmConstructionlogForPage(ViewBag.pageNum, ViewBag.numPerPage, "Clc_ConstructionDate", out totalRecord, sql);
            //总条数
            ViewBag.totalcount = totalRecord;
            //总页数
            ViewBag.pagenumshown = totalRecord % ViewBag.numPerPage == 0 ? totalRecord / ViewBag.numPerPage : totalRecord / ViewBag.numPerPage + 1;
            return View("ConstructionLogCivilList", new PlmConstructionlogcivilViewModel { ThePlmConstructlogcivilList = list });
        }



    }
}
